﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using Dal;
using System.Data;

namespace Bll
{
    public class BllAdmin
    {
        DalAdmin d = new DalAdmin();

        public bool Login(ModelAdmin m)
        {
            return d.Login(m);
        }
        public string Admin_Grade(ModelAdmin m)
        {
            //管理员权限      
            return d.Admin_Grade(m);
        }
        public string Admin_Name(ModelAdmin m)
        {
            return d.Admin_Name(m);
        }

        public string Admin_Type(ModelAdmin m)
        {
            return d.Admin_Type(m);
        }

        public string Add(ModelAdmin m)
        {
            //添加管理员


            if (m.Acc == "")
            {
                return "管理员账号不能为空!";
            }
            if (m.Acc.Length < 5&&m.Acc.Length>12)
            {
                return "管理员账号不能少于5位或大于12位";
            }
            if (m.Pwd == "")
            {
                return "管理员密码不能为空!";
            }
            if (m.Pwd.Length <= 5&&m.Pwd.Length>12)
            {
                return "管理员密码不能少于5位或大于12位";
            }
            if (m.Name == "")
            {
                m.Name = m.Acc;
            }
            if (m.Grade != "")
            {
                return d.Add(m);
            }
            else
            {
                return "请选择管理员权限!";
            }

        }

        public DataTable All_Information(ModelAdmin m)
        {
            //显示数据
            return d.All_Information(m);
        }

        public string Data_Delete(ModelAdmin m)
        {
            //删除管理员
            if (d.Data_Delete(m) == true)
            {
                return "删除成功！";
            }
            return "删除失败！";
        }

        public bool Update_Information(ModelAdmin m)
        {
            //管理员更新
            return d.Update_Information(m);
        }

        public DataTable Singlex_Information(ModelAdmin m)
        {
            return d.Singlex_Information(m);
        }
    }
}
